# numbers = [2, 7, 11, 15]
# # i = 1
# # target = 9
# # # for i in range(len(numbers)):
# # #     s = target - numbers[i]
# # #     for j in range(len(numbers)):
# # #         if j == i:
# # #             break
# # #         else:
# # #             if numbers[j] == s:
# # #                 print(i,j)
# # #                 break
# # s = numbers[i+1:]
# # j = numbers.index(7)
# # print(s)
# # print(j)

# numbers = [1,2,7,11,15]
# target = 9
# for i in range(len(numbers)):
#     s = target - numbers[i]
#     temp = numbers[i+1:]
#     if s in temp:
#         j = temp.index(s)
#         print(i+1,i+1+j+1)

# import re
# str = """img data-original="https://rpic.douyucdn.cn/appCovers/2016/11/13/1213973_201611131917_small.jpg" src="https://rpic.douyucdn.cn/appCovers/2016/11/13/1213973_201611131917_small.jpg" style="display: inline;"""
# print(re.search(r"https://.*?\.jpg", str).group())

# coding=utf-8

#
# class Person(object):
#     def __init__(self, name, age, taste):
#         self.name = name
#         self._age = age
#         self.__taste = taste
#
#     def showperson(self):
#         print(self.name)
#         print(self._age)
#         print(self.__taste)
#
#     def dowork(self):
#         self._work()
#         self.__away()
#
#     def _work(self):
#         print('my _work')
#
#     def __away(self):
#         print('my __away')
#
#
# class Student(Person):
#     def construction(self, name, age, taste):
#         self.name = name
#         self._age = age
#         self.__taste = taste
#
#     def showstudent(self):
#         print(self.name)
#         print(self._age)
#         print(self.__taste)
#
#     @staticmethod
#     def testbug():
#         _Bug.showbug()
#
# # 模块内可以访问，当from  cur_module import *时，不导入
#
#
# class _Bug(object):
#     @staticmethod
#     def showbug():
#         print("showbug")
#
#
# s1 = Student('jack', 25, 'football')
# s1.showperson()
# print('*' * 20)
#
# # 无法访问__taste,导致报错
# # s1.showstudent()
# s1.construction('rose', 30, 'basketball')
# s1.showperson()
# print('*' * 20)
#
# s1.showstudent()
# print('*' * 20)
#
# Student.testbug()

# import numpy as np
# # arr = np.arange(16)
# # print(arr.reshape(2, 2, 4))
#
# # arr = np.array([[1,2,3],
# #                 [4,5,6]])
# # print(2+arr)
# arr = [[1,2,3],
#        [4,5,6]]
# print(np.multiply(arr,arr))

import numpy as np

filename = "./presidential_polls.csv"
# data_array = np.loadtxt(filename,
#                         delimiter=",",
#                         dtype=str,
#                         usecols=(0,2,3))
# print(data_array,data_array.shape)

with open(filename, "r") as f:
    col_names_str = f.readline()[:-1]
#
col_name_lst = col_names_str.split(",")
use_col_name_lst = ['enddate',
                    'rawpoll_clinton',
                    'rawpoll_trump',
                    'adjpoll_clinton',
                    'adjpoll_trump']
use_col_index_lst = [col_name_lst.index(use_col_name) for use_col_name in use_col_name_lst]
data_array = np.genfromtxt(filename,
                           delimiter=",",
                           dtype=str,
                           usecols=use_col_index_lst)
data_array = data_array[1:]
print(data_array[1:], data_array.shape)


